<?php

namespace App\Http\Controllers\Api\User;

use App\Http\Controllers\ApiController;
use App\Models\CopartnerApply;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

class CoperateController extends ApiController
{
    public function apply_coperate(Request $request,CopartnerApply $copartnerApply)
    {
        $validator = \Validator::make($request->all(),[
            'phone'         => 'required',
            'true_name'     => 'required',
            'idcardnum'     => 'required',
            'shop_name'     => 'required',
            'shop_address'  => 'required',
            'user_id'       => 'required'
        ]);
        if($validator->fails()){
            return self::response(null,self::ERROR_CODE,$validator);
        }

        if(!$copartnerApply -> copartner_apply($request->all())){
           return self::response(null,self::ERROR_CODE,CopartnerApply::$error);
        }

        return self::response(null,self::SUC_CODE,'申请成功');
    }
}
